

**** HOUSEHOLD LEVEL REGRESSIONS (Table H.20 - Table H.23) 

use "$datadir/consumption/finaldata_hh_eventtime.dta", clear
	cap drop invshare_sd
	cap drop l_preshockdeposit
	
	*** add number of ATMs
	merge m:1 district state using "$datadir\banking\district_atm.dta"
	drop if _m==2
	drop _m
	
	
	** add banking deposit data
	merge m:1  state district using "$datadir/banking/adjusted_deposit.dta", keepusing(state district  preshock_deposit) keep(match) nogenerate 
	**
	g l_preshockdeposit = ln(1+preshock_deposit)
	label var l_preshockdeposit "Log(pre-shock deposits)"
	
	** attach district controls
	merge m:1 district state using "$datadir\districts\districtcontrols.dta", update replace
	drop if (_m == 1 | _m == 2)
	drop _m
	**
	
	* merge with chest measure 
	merge m:1 district state using "$datadir\banking\chest_exposure_full.dta", keepusing(state district invshare_sd) keep(match) nogenerate 
	forval i=1/4{
		g treat`i'Xinvshare_sd = treat`i'*invshare_sd
	}
	

	xtset HH_ID event_time
	***************************************************************************	
	*above 75
	gen vhigh_invshare=0
	replace vhigh_invshare=1 if invshare_sd>0.6601795
	
	forval i=1/4{
		g treat`i'Xvhinvshare = treat`i'*vhigh_invshare
	}

	gen atm_pop=num_atm/POP_T 
	gen l_atm_pop=ln(atm_pop)	
	sum atm_pop if event_time==0, d
		
	*Above median
	gen high_atmpop=(atm_pop>0.0000884 )
	replace high_atmpop=. if num_atm==.
	
	forval i=1/4{
		foreach gr in high_atmpop {

		g treat`i'Xvhinvshare_`gr'  = treat`i'*vhigh_invshare*`gr'
		g treat`i'Xinvshare_sd_`gr' = treat`i'*invshare_sd*`gr'
		g treat`i'_`gr' = treat`i'*`gr'

		}
		}

	gen log1_hh_expense_billsrent=ln(1+EXPENSE_ON_BILLS_AND_RENT)
	gen nec_1 = EXPENSE_ON_FOOD  + EXPENSE_ON_BILLS_AND_RENT + EXPENSE_ON_POWER_AND_FUEL 
	gen unnec_1=TOTAL_EXPENDITURE-nec_1
	foreach var of varlist nec_* unnec_* {
		cap drop l_`var'
		gen l_`var'=ln(`var'+1)
	}
	
	egen district_event_time=group(district_id event_time)
	egen state_time=group(state event_time)
	
	** each post-treatment event time separately
	set more off
	local month_start = -4	
	local month_end = 4
	
	** Table H.20
	local controls "(c.log_mrain_adj c.l_income_pre c.l_age_pre c.l_preshockdeposit c.s_status_atm c.s_status_commercialbank c.logpop_T c.share_rural)"
    reghdfe log_hh_expense_total treat1Xinvshare_sd treat2Xinvshare_sd treat3Xinvshare_sd treat4Xinvshare_sd  if event_time >=-2 & event_time <=+4 , a(HH_ID i.event_time `controls'##i.event_time) cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_20.tex", replace
	reghdfe log_hh_expense_total treat1Xvhinvshare treat2Xvhinvshare treat3Xvhinvshare treat4Xvhinvshare  if event_time >=-2 & event_time <=+4 , a(HH_ID i.event_time `controls'##i.event_time) cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_20.tex", append
	
	** Table H.21
	local controls "(c.log_mrain_adj c.l_income_pre c.l_age_pre c.l_preshockdeposit c.s_status_atm c.s_status_commercialbank c.logpop_T c.share_rural)"
	reghdfe l_nec_1 treat1Xinvshare_sd treat2Xinvshare_sd treat3Xinvshare_sd treat4Xinvshare_sd  if event_time >=-2 & event_time <=+4 , a(HH_ID i.event_time `controls'##i.event_time) cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_21.tex",  keep(treat1Xinvshare_sd)  replace	
    foreach var of varlist  l_unnec_1 log1_hh_expense_billsrent log1_hh_expense_food log1_hh_expense_recreation {
		reghdfe `var' treat1Xinvshare_sd treat2Xinvshare_sd treat3Xinvshare_sd treat4Xinvshare_sd  if event_time >=-2 & event_time <=+4 , a(HH_ID i.event_time `controls'##i.event_time) cluster(district_id)
		outreg2 using "$outputdir_tab\Table_H_21.tex",  keep(treat1Xinvshare_sd) append	
	}
	
	** Table H.22
	local controls "(c.log_mrain_adj c.l_income_pre c.l_age_pre c.l_preshockdeposit c.s_status_atm c.s_status_commercialbank c.logpop_T c.share_rural)"
	reghdfe log_hh_expense_total treat1Xvhinvshare treat2Xvhinvshare treat3Xvhinvshare treat4Xvhinvshare  if event_time >=-2 & event_time <=+4 , a(HH_ID i.event_time `controls'##i.event_time) cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_22.tex", replace
	reghdfe l_nec_1 treat1Xvhinvshare treat2Xvhinvshare treat3Xvhinvshare treat4Xvhinvshare  if event_time >=-2 & event_time <=+4 , a(HH_ID i.event_time `controls'##i.event_time) cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_22.tex", append
	reghdfe l_unnec_1 treat1Xvhinvshare treat2Xvhinvshare treat3Xvhinvshare treat4Xvhinvshare  if event_time >=-2 & event_time <=+4 , a(HH_ID i.event_time `controls'##i.event_time) cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_22.tex", append
	
	*** Table H.23
	local month_start = -2	
	local month_end = 4
	local controls "(c.log_mrain_adj c.l_income_pre c.l_age_pre c.l_preshockdeposit c.s_status_atm c.s_status_commercialbank c.logpop_T c.share_rural)"
	reghdfe log_hh_expense_total treat1Xinvshare_sd_high_atmpop treat2Xinvshare_sd_high_atmpop treat3Xinvshare_sd_high_atmpop treat4Xinvshare_sd_high_atmpop  treat1_high_atmpop treat2_high_atmpop   treat3_high_atmpop   treat4_high_atmpop    treat1Xinvshare_sd treat2Xinvshare_sd treat3Xinvshare_sd treat4Xinvshare_sd   if event_time >= `month_start' & event_time <= `month_end'  , a(HH_ID i.event_time   `controls'##i.event_time) cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_23.tex", replace 
	reghdfe log_hh_expense_total treat1Xvhinvshare_high_atmpop treat2Xvhinvshare_high_atmpop treat3Xvhinvshare_high_atmpop treat4Xvhinvshare_high_atmpop  treat1_high_atmpop treat2_high_atmpop   treat3_high_atmpop   treat4_high_atmpop    treat1Xvhinvshare treat2Xvhinvshare treat3Xvhinvshare treat4Xvhinvshare   if event_time >= `month_start' & event_time <= `month_end'  , a(HH_ID i.event_time   `controls'##i.event_time) cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_23.tex", append
	foreach var of varlist   l_nec_1 l_unnec_1  {
    	reghdfe `var'  treat1Xinvshare_sd_high_atmpop treat2Xinvshare_sd_high_atmpop treat3Xinvshare_sd_high_atmpop treat4Xinvshare_sd_high_atmpop  treat1_high_atmpop treat2_high_atmpop   treat3_high_atmpop   treat4_high_atmpop    treat1Xinvshare_sd treat2Xinvshare_sd treat3Xinvshare_sd treat4Xinvshare_sd   if event_time >= `month_start' & event_time <= `month_end'  , a(HH_ID i.event_time   `controls'##i.event_time) cluster(district_id)
		outreg2 using "$outputdir_tab\Table_H_23.tex", append 
		reghdfe `var'  treat1Xvhinvshare_high_atmpop treat2Xvhinvshare_high_atmpop treat3Xvhinvshare_high_atmpop treat4Xvhinvshare_high_atmpop  treat1_high_atmpop treat2_high_atmpop   treat3_high_atmpop   treat4_high_atmpop    treat1Xvhinvshare treat2Xvhinvshare treat3Xvhinvshare treat4Xvhinvshare   if event_time >= `month_start' & event_time <= `month_end'  , a(HH_ID i.event_time   `controls'##i.event_time) cluster(district_id)
		outreg2 using "$outputdir_tab\Table_H_23.tex", append
	}

	
	
	
